package process_control;

import java.util.Scanner;

public class P2_ScannerPro {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        /* 从键盘接收数据 */
        int i = 0;
        float f = 0.0f;
        System.out.println("please Input INT: ");
        /* check INT */
        if (scn.hasNextInt()) {
            i = scn.nextInt();
            System.out.println("INT: " + i);
        }else {
            System.out.println("error: Intput is not INT.");
        }

        System.out.println("please Input FLOAT: ");
        /* check FLOAT */
        if (scn.hasNextFloat()) {
            f = scn.nextFloat();
            System.out.println("FLOAT: " + i);
        }else {
            System.out.println("error: Input is not FLOAT.");
        }

        // 关闭对象
        scn.close();

    }
}
